{include file="common/head"/}
<style>
    .layui-table-cell{height: auto;}
    .layui-table-cell ul li a{color: #1C8FEF;display: block;border: 1px solid #ececec;padding: 3px 8px;}
    .layui-table-cell ul li a:hover{color: #005580}
</style>
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>学生档案</legend>
    </fieldset>
    <div class="layui-inline" style="float: right">
        <form class="layui-form" action="">
            <div class="layui-form-item" style="margin-bottom: 0px">

                <div class="layui-inline" style="margin-right: 0px">
                    <!--<label class="layui-form-label">密码</label>-->
                    <div class="layui-input-inline" style="width: 200px;">
                        <input type="text" id="keyword" name="keyword" autocomplete="off"
                               placeholder="请输入学生姓名/学生编号"
                               class="layui-input">
                    </div>
                </div>

                <div class="layui-inline" style="margin-right: 0px">
                    <div class="layui-btn-group layui-inline" style="margin: 0px">
                        <!--此重置 仅仅是个跳转链接-->
                        <a  href="{:url('admin/student/index')}" class="layui-btn layui-btn-primary">重置</a>
                        <button id="search" class="layui-btn layui-btn-normal" type="button" lay-submit lay-filter="formDemo" style="background-color: #009688;">
                            <i class="layui-icon">&#xe615;</i>查找
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <!--<div class="demoTable">-->
        <!--<a href="{:url('addMedia',['url'=>'materialmessage'])}" class="layui-btn layui-btn-sm" style="float:right;margin-right: 15px;">{:lang('add')}</a>-->
    <!--</div>-->
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
<!--<script type="text/html" id="action">-->
    <!--<a href="{:url('updatemedia')}?media_id={{d.media_id}}" class="layui-btn layui-btn-xs">编辑</a>-->
    <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
<!--</script>-->
<script type="text/html" id="student_sn">
    {{d.student_sn}}
</script>
<script type="text/html" id="name">
    {{d.true_name}}
</script>
<script type="text/html" id="student_number">
    {{d.student_number}}
</script>
<!--<script type="text/html" id="school_name">-->
    <!--{{d.school_name}}-->
<!--</script>-->
<!--<script type="text/html" id="school_code">-->
    <!--{{d.school_code}}-->
<!--</script>-->
<script type="text/html" id="grade_name">
    {{d.grade_name}}
</script>
<script type="text/html" id="class_name">
    {{d.class_name}}
</script>
<script type="text/html" id="mobile">
    {{d.mobile}}
</script>
<script type="text/html" id="add_parentname">
    {{d.add_parentname}}
</script>
<script type="text/html" id="hostel">
    <input type="checkbox" name="hostel" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="hostel" {{ d.hostel == 1 ? 'checked' : '' }}>
</script>
{include file="common/foot"/}
<script>
    layui.use(['table','form'],function() {
        var table = layui.table, form = layui.form,$ = layui.jquery;
        var tableIn = table.render({
            id: 'user',
            elem: '#list',
            url: "{:url('index')}",
            method: 'post',
            page: true,
            even:true,
            cols: [[
                {field: 'name', title: '学生姓名', width: 100,templet:'#name'},
                {field: 'student_number',title: '学生编号', width: 150,style:'height: auto;',templet:'#student_number'},
                // {field: 'school_name',title: '学校', width: 150,style:'height: auto;',templet:'#school_name'},
                // {field: 'school_code',title: '学校代码', width: 150,style:'height: auto;',templet:'#school_code'},
                {field: 'grade_name',title: '年级', width: 100,style:'height: auto;',templet:'#grade_name'},
                {field: 'class_name',title: '班级', width: 100,style:'height: auto;',templet:'#class_name'},
                {field: 'student_sn',title: '学号', width: 120,style:'height: auto;',templet:'#student_sn'},

                {field: 'mobile',title: '手机号', width: 120,style:'height: auto;',templet:'#mobile'},
                {field: 'add_parentname',title: '添加人', width: 120,style:'height: auto;',templet:'#add_parentname'},
                {field: 'add_time', title: '添加时间', width: 180},
                {field: 'hostel', align: 'center', title: '是否外宿', width: 100, toolbar: '#hostel'},

                // {width: 160, align: 'center', toolbar: '#action'}
            ]],
            limit: 10 //每页默认显示的数量
        });
        $('#search').on('click', function () {

            var keyword = $('#keyword').val();
            console.log(keyword);

            if ($.trim(keyword) === '') {
                layer.msg('{:lang("pleaseEnter")}查找信息！', {icon: 0});
                return;
            }
            //表格重载
            tableIn.reload({
                //传递额外参数
                where: {keyword: keyword}

            });
        });
        form.on('switch(hostel)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = this.value;
            var status = obj.elem.checked===true?1:2;
            console.log('123456');
            $.post('{:url("editState")}',{'id':id,'status':status},function (res) {
                console.log('99999');
                layer.close(loading);
                if (res.code==1) {
                    tableIn.reload();
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                    return false;
                }
            })
        });

    });
</script>
</body>
</html>